package entity.tx;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.OneToOne;
import javax.persistence.OneToMany;
import java.util.List;
import java.util.ArrayList;
import java.util.Calendar;
import javax.persistence.FetchType;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @Written by T12 (IS3102 AY2011/12)
 */
@Entity
public class PerformanceItem extends Item implements Serializable{
    private static final long serialVersionUID = 1L;
    private String eventPoster;
    private String eventRating;
    private String eventLanguage;
    private Integer eventDuration;
    private String eventGenre;
    private String eventType;
    @Temporal(value = TemporalType.TIMESTAMP)
    private Calendar startDate;
    @Temporal(value = TemporalType.TIMESTAMP)
    private Calendar endDate;
    @OneToMany(fetch=FetchType.EAGER)
    private List<Showing> show = new ArrayList<Showing>();
    
    public PerformanceItem(){
        
    }
    
    public void create(String eventName, String eventPoster, String description, String eventRating, 
            String eventLanguage, int eventDuration, String type, String genre, Calendar startDate, Calendar endDate){
        this.setName(eventName);
        this.setDescription(description);
        this.setEventPoster(eventPoster);
        this.setEventDuration(eventDuration);
        this.setEventGenre(genre);
        this.setEventType(type);
        this.setEventLanguage(eventLanguage);
        this.setEventRating(eventRating);
        this.setStartDate(startDate);
        this.setEndDate(endDate);
    }

    public Calendar getEndDate() {
        return endDate;
    }

    public void setEndDate(Calendar endDate) {
        this.endDate = endDate;
    }

    public Integer getEventDuration() {
        return eventDuration;
    }

    public void setEventDuration(Integer eventDuration) {
        this.eventDuration = eventDuration;
    }

    public String getEventLanguage() {
        return eventLanguage;
    }

    public void setEventLanguage(String eventLanguage) {
        this.eventLanguage = eventLanguage;
    }

    public String getEventRating() {
        return eventRating;
    }

    public void setEventRating(String eventRating) {
        this.eventRating = eventRating;
    }

    public String getEventGenre() {
        return eventGenre;
    }

    public void setEventGenre(String eventGenre) {
        this.eventGenre = eventGenre;
    }

    public String getEventType() {
        return eventType;
    }

    public void setEventType(String eventType) {
        this.eventType = eventType;
    }

    public Calendar getStartDate() {
        return startDate;
    }

    public void setStartDate(Calendar startDate) {
        this.startDate = startDate;
    }

    public List<Showing> getShow() {
        return show;
    }

    public void setShow(List<Showing> show) {
        this.show = show;
    }

    public String getEventPoster() {
        return eventPoster;
    }

    public void setEventPoster(String eventPoster) {
        this.eventPoster = eventPoster;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PerformanceItem)) {
            return false;
        }
        PerformanceItem other = (PerformanceItem) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "EventTicketing.Event[ id=" + id + " ]";
    }
}
